import axios from "axios"
import { Turnout, WifiDevice, DeviceFunctionalConfig } from "../models"

export const getDevices = async (): Promise<WifiDevice[]> => {
    const resp = axios.get('/api/devices/all')
    return (await resp).data
}

export const getDeviceConfigs = async (): Promise<DeviceFunctionalConfig[]> => {
    const resp = axios.get('/api/devices/all-configs')
    const data = (await resp).data
    console.log("data", data)
    return data
}

export const saveDeviceConfigs = async (configs: DeviceFunctionalConfig[]): Promise<void> => {
    console.log("configs", configs)
    const resp = await axios.post('/api/devices/save-configs', configs)
    console.log("resp", resp)
}
